c# use list as a paramter

34

c# use list as a paramter -

You should always avoid using List<T> as a parameter.
Not only because this pattern reduces the opportunities of the caller to store the data
in a different kind of collection,but also the caller has to convert the data into a 
List first.Converting an IEnumerable into a List costs O(n) complexity which
is absolutely unneccessary. And it also creates a new object.
TL;DR you should always use a proper interface like IEnumerable or IQueryable based 
on what do you want to do with your collection. ;)

In your case:

public void foo(IEnumerable<DateTime> dateTimes)
{
}

c# use list as a paramter -

You should always avoid using List<T> as a parameter.
Not only because this pattern reduces the opportunities of the caller to store the data
in a different kind of collection,but also the caller has to convert the data into a 
List first.Converting an IEnumerable into a List costs O(n) complexity which
is absolutely unneccessary. And it also creates a new object.
TL;DR you should always use a proper interface like IEnumerable or IQueryable based 
on what do you want to do with your collection. ;)

In your case:

public void foo(IEnumerable<DateTime> dateTimes)
{
}

c# use list as a paramter -

You should always avoid using List<T> as a parameter.
Not only because this pattern reduces the opportunities of the caller to store the data
in a different kind of collection,but also the caller has to convert the data into a 
List first.Converting an IEnumerable into a List costs O(n) complexity which
is absolutely unneccessary. And it also creates a new object.
TL;DR you should always use a proper interface like IEnumerable or IQueryable based 
on what do you want to do with your collection. ;)

In your case:

public void foo(IEnumerable<DateTime> dateTimes)
{
}

c# use list as a paramter -

You should always avoid using List<T> as a parameter.
Not only because this pattern reduces the opportunities of the caller to store the data
in a different kind of collection,but also the caller has to convert the data into a 
List first.Converting an IEnumerable into a List costs O(n) complexity which
is absolutely unneccessary. And it also creates a new object.
TL;DR you should always use a proper interface like IEnumerable or IQueryable based 
on what do you want to do with your collection. ;)

In your case:

public void foo(IEnumerable<DateTime> dateTimes)
{
}

c# use list as a paramter -

You should always avoid using List<T> as a parameter.
Not only because this pattern reduces the opportunities of the caller to store the data
in a different kind of collection,but also the caller has to convert the data into a 
List first.Converting an IEnumerable into a List costs O(n) complexity which
is absolutely unneccessary. And it also creates a new object.
TL;DR you should always use a proper interface like IEnumerable or IQueryable based 
on what do you want to do with your collection. ;)

In your case:

public void foo(IEnumerable<DateTime> dateTimes)
{
}

c# use list as a paramter -

You should always avoid using List<T> as a parameter.
Not only because this pattern reduces the opportunities of the caller to store the data
in a different kind of collection,but also the caller has to convert the data into a 
List first.Converting an IEnumerable into a List costs O(n) complexity which
is absolutely unneccessary. And it also creates a new object.
TL;DR you should always use a proper interface like IEnumerable or IQueryable based 
on what do you want to do with your collection. ;)

In your case:

public void foo(IEnumerable<DateTime> dateTimes)
{
}

c# use list as a paramter -

You should always avoid using List<T> as a parameter.
Not only because this pattern reduces the opportunities of the caller to store the data
in a different kind of collection,but also the caller has to convert the data into a 
List first.Converting an IEnumerable into a List costs O(n) complexity which
is absolutely unneccessary. And it also creates a new object.
TL;DR you should always use a proper interface like IEnumerable or IQueryable based 
on what do you want to do with your collection. ;)

In your case:

public void foo(IEnumerable<DateTime> dateTimes)
{
}

c# use list as a paramter -

You should always avoid using List<T> as a parameter.
Not only because this pattern reduces the opportunities of the caller to store the data
in a different kind of collection,but also the caller has to convert the data into a 
List first.Converting an IEnumerable into a List costs O(n) complexity which
is absolutely unneccessary. And it also creates a new object.
TL;DR you should always use a proper interface like IEnumerable or IQueryable based 
on what do you want to do with your collection. ;)

In your case:

public void foo(IEnumerable<DateTime> dateTimes)
{
}

c# use list as a paramter -

You should always avoid using List<T> as a parameter.
Not only because this pattern reduces the opportunities of the caller to store the data
in a different kind of collection,but also the caller has to convert the data into a 
List first.Converting an IEnumerable into a List costs O(n) complexity which
is absolutely unneccessary. And it also creates a new object.
TL;DR you should always use a proper interface like IEnumerable or IQueryable based 
on what do you want to do with your collection. ;)

In your case:

public void foo(IEnumerable<DateTime> dateTimes)
{
}

Comments

Submit
0 Comments